package com.avcdata.aoscustommade.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by c.c on 2017/2/26.
 * 共享参数类
 */
public class SharedPreferencesUtils {
    private SharedPreferences userInfoSp;
    private SharedPreferences deviceSp;
    private SharedPreferences installSp;
    private SharedPreferences otherSp;

    private SharedPreferences.Editor userInfoEditor;
    private SharedPreferences.Editor deviceEditor;
    private SharedPreferences.Editor installEditor;
    private SharedPreferences.Editor otherEditor;

    public SharedPreferencesUtils(Context context) {
        userInfoSp = context.getSharedPreferences("user_info", Context.MODE_PRIVATE);
        userInfoEditor = userInfoSp.edit();

        deviceSp = context.getSharedPreferences("device_info",Context.MODE_PRIVATE);
        deviceEditor = deviceSp.edit();

        installSp = context.getSharedPreferences("install_info",Context.MODE_PRIVATE);
        installEditor = installSp.edit();

        otherSp = context.getSharedPreferences("other_info",Context.MODE_PRIVATE);
        otherEditor = otherSp.edit();
    }
    //清除用户信息
    public void clearUserInfo() {
        userInfoEditor.clear().commit();
    }

    //账号
    public void setUserAccount(String account) {
        userInfoEditor.putString(AvcConstants.USERACCOUNT,account).commit();
    }
   public String getUserAccount() {
        return userInfoSp.getString(AvcConstants.USERACCOUNT,"");
    }

    //手机
    public void setUserPhone(String phone) {
        userInfoEditor.putString(AvcConstants.USERPHONE,phone).commit();
    }
    public String getUserPhone() {
        return userInfoSp.getString(AvcConstants.USERPHONE,"");
    }

    //邮箱
    public void setUserEmail(String email) {
        userInfoEditor.putString(AvcConstants.USEREMAIL,email).commit();
    }
    public String getUserEmail() {
        return userInfoSp.getString(AvcConstants.USEREMAIL,"");
    }


    //密码
    public void setUserPassword(String password) {
        userInfoEditor.putString(AvcConstants.USERPASSWORD,password).commit();
    }
    public String getUserPassword() {
        return userInfoSp.getString(AvcConstants.USERPASSWORD,"");
    }


    //存储key
    public void setKey(String password) {
        userInfoEditor.putString(AvcConstants.USERKEY,password).commit();
    }
    public String getKey() {
        return userInfoSp.getString(AvcConstants.USERKEY,"");
    }

    //密码是否可见
    public void setPasswordShow(boolean type) {
        installEditor.putBoolean(AvcConstants.USERPASSWORDSHOW,type).commit();
    }
    public boolean getPasswordShow() {
        return installSp.getBoolean(AvcConstants.USERPASSWORDSHOW,false);
    }

    //记住密码
    public void setRememberPassword(boolean type) {
        installEditor.putBoolean(AvcConstants.USERPASSWORD,type).commit();
    }
    public boolean getRememberPassword() {
        return installSp.getBoolean(AvcConstants.USERPASSWORD,false);
    }

    //sessionId
    public void setSessionId(String sessionId) {
        userInfoEditor.putString(AvcConstants.USERSESSIONID,sessionId).commit();
    }
    public String getSessionId() {
        return userInfoSp.getString(AvcConstants.USERSESSIONID,"");
    }


    //最新周的选取
    public void setNewWeek(String sessionId) {
        userInfoEditor.putString(AvcConstants.USERGETNEWWEEK,sessionId).commit();
    }
    public String getNewWeek() {
        return userInfoSp.getString(AvcConstants.USERGETNEWWEEK,"");
    }


    //用户权限
    public void setUserLimits(String limit) {
        userInfoEditor.putString(AvcConstants.USERLIMIT,limit).commit();
    }
    public String getUserLimits() {
        return userInfoSp.getString(AvcConstants.USERLIMIT,"1");
    }












}
